using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XCZProject;

public class DamageSystem
{
    /// <summary>
    /// 计算给敌人造成的伤害
    /// </summary>
    /// <param name="baseDamage">基础伤害</param>
    /// <param name="enemy">敌人</param>
    /// <param name="maxNormalDamage">最大默认伤害</param>
    /// <param name="cirticalDamageTime">暴击倍数</param>
    public static void CalculateDamage(float baseDamage,IEnemy enemy, int maxNormalDamage=2,float cirticalDamageTime=5)
    {
        // 获取基础伤害值
        baseDamage *= Global.DamageRate.Value;
        // 判断是否暴击
        if (Random.Range(0,1.0f)<Global.CriticalRate.Value)
        {
            enemy.Hurt(baseDamage*Random.Range(2f,cirticalDamageTime),false,true);
        }
        else
        {
            enemy.Hurt(baseDamage+Random.Range(-1,maxNormalDamage));
        }
    }
}
